* Per talk with brion, use wfArrayToCGI()\n* Avoid blank lines between CSS <link>
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 28 Jul 2008 19:10:13 +0000 (19:10 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 28 Jul 2008 19:10:13 +0000 (19:10 +0000)
includes/SkinTemplate.php

index 886809a..cd1568f 100644 (file)
@@ -959,17 +959,6 @@ class SkinTemplate extends Skin {
                return $this->mTitle->getNamespaceKey();
        }
 
-       /**
-        * Callback to get args for CSS query string, a bit like wfArrayTpCGI, but
-        * does not escape args
-        *
-        * @param $val
-        * @param $key
-        */
-       static function cssWalkCallback( &$val, $key ){
-               $val = "$key=$val";
-       }
-
        /**
         * @private
         */
@@ -992,15 +981,13 @@ class SkinTemplate extends Skin {
                // If we use the site's dynamic CSS, throw that in, too
                // Per-site custom styles
                if ( $wgUseSiteCss ) {
-                       $query = array(
+                       $query = wfArrayToCGI( array(
                                'usemsgcache' => 'yes',
                                'ctype' => 'text/css',
                                'smaxage' => $wgSquidMaxage
-                       ) + $siteargs;
-                       array_walk( $query, array( __CLASS__, 'cssWalkCallback' ) );
-                       $queryString = implode( '&', $query );
-                       $this->addStyle( self::makeNSUrl( 'Common.css', $queryString, NS_MEDIAWIKI ) );
-                       $this->addStyle( self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $queryString, NS_MEDIAWIKI ),
+                       ) + $siteargs );
+                       $this->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) );
+                       $this->addStyle( self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ),
                                'screen' );
                }
 
@@ -1008,8 +995,7 @@ class SkinTemplate extends Skin {
                $siteargs['gen'] = 'css';
                if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' )
                        $siteargs['useskin'] = $us;
-               array_walk( $siteargs, array( __CLASS__, 'cssWalkCallback' ) );
-               $this->addStyle( self::makeUrl( '-', implode( '&', $siteargs ) ), 'screen' );
+               $this->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ), 'screen' );
 
                // Per-user custom style pages
                if ( $wgAllowUserCss && $this->loggedin ) {
@@ -1134,7 +1120,9 @@ class SkinTemplate extends Skin {
         */
        protected function buildCssLinks() {
                foreach( $this->styles as $file => $options ) {
-                       $links[] = $this->styleLink( $file, $options );
+                       $link = $this->styleLink( $file, $options );
+                       if( $link )
+                               $links[] = $link;
                }
                
                return implode( "\n\t\t", $links );